package com.xg.serviceverificationcode.controller;

import com.xg.common.result.ApiResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 提供验证码
 */
@RestController
public class VerificationCodeController {

    /**
     * 获取验证码
     * @param size
     * @return
     */
    @RequestMapping("/verification-code/{size}")
    public ApiResult<String> getVerificationCode(@PathVariable("size") int size){
        int code = (int) ((Math.random() * 9 + 1)*Math.pow(10,size-1));

        return ApiResult.success(code);
    }

}
